import java.util.*;

/**
 * @author LKQ
 * @date 2022/7/2 11:34
 * @description
 */
public class Solution {
    public static void main(String[] args) {

    }
    public int countDistinct(int[] nums, int k, int p) {
        Set<Arr> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            int cnt = k;
            for (int j = i; j < nums.length; j++) {
                if (nums[j] % p == 0) {
                    cnt--;
                }
                if (cnt >= 0) {
                    set.add(new Arr(Arrays.copyOfRange(nums, i, j + 1)));
                }
            }
        }
        return set.size();
    }

    private static class Arr{
        int[] nums;

        public Arr(int[] a) {
            nums = a;
        }

        @Override
        public boolean equals(Object o) {
            if (o == this) {
                return true;
            }
            if (!(o instanceof Arr)) {
                return false;
            }
            Arr arr = (Arr) o;
            return Arrays.equals(nums, arr.nums);
        }

        @Override
        public int hashCode() {
            return Arrays.hashCode(nums);
        }
    }
}
